home *** CD-ROM | disk | FTP | other *** search
/ Software USA 4 #5 / Software USA Volume 4.05.iso / mac / Education / HTML Tricks / Extreme Mac HTML Tricks v2.1 / Extreme Mac HTML Tricks v2.1.rsrc / TEXT_141.txt < prev    next >
Text File  |  1996-10-31  |  7KB  |  237 lines

  1.  
  2.  
  3.     Forms are the most complicated part on making a web page. You need many things to make a form function. You need the html code (the actual making of the form), and the cgi script that has to be on your server. When a user fills out a form and hits the submit button, it notifies your server and acceses the script. Then the  script grabs the data, and sends it to your specified location. It could either mail it to you, or write it to another page, like a guestbook. Unfortunatly, I don't know scripting languages, but I do know how to make the html code for your form on your web page.
  4. I'll just show you the code and what it would look like on your web page. 
  5.  
  6.     I'll start off by showing you how to make a basic text box.
  7. ¬†It's very easy to make                                   this text box. It has a defined length to it, but a person is able to write a book inside of it. (No defined text length limit)       
  8.  
  9. Below is the code I used:
  10. <FORM >
  11. <INPUT NAME="Example1" >
  12. </FORM>
  13.  
  14. It's time to bring you on a step by step process of making your own servay. Follow along while making your own form for your web visitors to fill out. You may edit it in any way when you get the hang of things. 
  15.  
  16. Lets Make a Servay! 
  17.  
  18. ‚Ä¢First lets ask the person their name and have it just be a simple text box like the one above. Just use this line of code:
  19. Name:<input name ="name">
  20.  
  21.  
  22.  
  23. Explanation
  24.  
  25. <INPUT ... > is the tag indicates that some form of input is to be inserted.
  26. With no TYPE specified, it defaults to a basic text box.
  27.  
  28. NAME="name" gives the name associated with the data that is returned.
  29. Each field must have a unique name so the entries can be identified.
  30.  
  31. Next comes the rest of the text on the form.
  32.  
  33.  
  34. ‚Ä¢Now ask them their age.
  35. Age: <input name="age" maxlength="3">
  36.  
  37.  
  38.  
  39.  
  40. Explanation
  41.  
  42. MAXLENGTH="3" tells the browser to only allow 3 characters (letters including spaces) to be entered as data for this field. 
  43.  
  44. ‚Ä¢Just for your learning reasons, ask them for a password.
  45.  
  46. Enter your password (up to 8 characters):<INPUT TYPE="password" NAME="userpassword" SIZE=8 MAXLENGTH=8 VALUE="default">
  47.  
  48.  
  49.  
  50. Explanation
  51.  
  52. SIZE="8" tells the browser to make room for 8 characters to show within
  53. the field. It makes the size of the text box itself.
  54.  
  55. MAXLENGTH="8" tells the browser to only allow 8 characters to be entered
  56. as data for this field, just like in the previous step. (Making SIZE and MAXLENGTH the same is good practice. It shows the user how much text you are expecting them to enter.)
  57.  
  58. ‚Ä¢Why don't you ask them if they like your page?
  59.  
  60. Do you like my page?<INPUT NAME="opinion" VALUE="Yes." >
  61.  
  62.  
  63. Explanation
  64. VALUE="Yes." tells the browser to put the text between the quotes into the field as the default answer. This is also shown in the password field in the previous step.
  65.  
  66. ‚Ä¢Wondering what their favorite fruit is? (Me Neither)
  67. What is your favorite fruit?
  68. <P>
  69. <SELECT NAME="fruit" >
  70. <OPTION>Apples
  71. <OPTION>Oranges
  72. <OPTION>Pears
  73. </SELECT> 
  74.  
  75.  
  76.  
  77.  
  78. Explanation
  79. The <select name="fruit"> just gives you the topic of the question being asked.
  80.  
  81. The <option> apples  gives you each choice to answer from. Here there are 3 choices. Apples, Oranges, or Pears. If you add more of the <option> in, you get more choices.
  82.  
  83. </select> tell your browser that the options are all done with.
  84.  
  85. ‚Ä¢Ask them to choose which months they like.
  86.  
  87. What months do you like below?
  88. <P>
  89. <INPUT TYPE="CHECKBOX" NAME="Jan"  CHECKED>January<BR>
  90. <INPUT TYPE="CHECKBOX" NAME="Feb" >February<BR>
  91. <INPUT TYPE="CHECKBOX" NAME="Mar"  CHECKED>March<BR>
  92. <INPUT TYPE="CHECKBOX" NAME="Apr" >April
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99. Explanation
  100. The <input type="checkbox" tells your browser it's a checkbox, and not a text field.
  101.  
  102. The checked> just gives the default months to be checked when first loaded.
  103.  
  104. ‚Ä¢Now to ask a serious question.
  105.  
  106. What is your favorite computer?
  107. <BR>
  108. <INPUT TYPE="radio" NAME="computer" VALUE="Macintosh">Macintosh <BR>
  109. <INPUT TYPE="radio" NAME="computer" VALUE="ibm" CHECKED>ibm<BR>
  110.  
  111.  
  112.  
  113. Explanation
  114. The <input type="radio" tells your browswer it's a radio button, not a checkbox or a text field.
  115.  
  116. Of course, nobody would ever capitalize ibm or ever think about checking that option.
  117.  
  118. ‚Ä¢Ask them to submit any comments that they might have.
  119. Please enter your comments:
  120. <TEXTAREA name="comments" ROWS=5 COLS=60>
  121. Some default comments
  122. </TEXTAREA>
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. Explanation
  131. <TEXTAREA name="comments" ROWS=5 COLS=60> this is what defines the text
  132. area. The tag for this type of input is <TEXTAREA>. It allows the other
  133. modifiers listed and has a closing tag. There is the usual name= that says
  134. what the data should be called when it is returned to your script. The next
  135. two items define the size of the form. ROWS=5 says that there should be room
  136. for 5 lines of text. The COLS=60 says that there should be room for 60
  137. characters per line. You can make the box as big as you like, but keep in
  138. mind that a traditional screen size is around 24 rows with 80 columns.
  139.  
  140. Some default comments: you can enter any default text you want in between
  141. the opening <TEXTAREA> and the next </TEXTAREA> tag.
  142.  
  143. </TEXTAREA> this is the closing portion of the text area tag. It indicates
  144. the end of this form element.
  145. (The picture of it above is scaled to fit your window screen size, so if you have a small monitor, 
  146. it will look somewhat distorted)
  147.  
  148. ‚Ä¢How do you make the 'Submit' and 'Reset' buttons?    
  149. <INPUT TYPE="SUBMIT" Value="Submit">
  150. <INPUT TYPE="RESET" Value="Reset">
  151.  
  152.  
  153.  
  154. Explanation
  155. I don't think you need an explaintion right? If you want to change the text inside from Submit to something else like 'Send' just edit the value="Submit"> to value="Send">.
  156.  
  157.     
  158.     Having fun yet? Well, lets put all this information you just learned together to make one large form. There are 2 tags that you must have at the begining and end of the entire form. They are <form> and </form> . You'll see this when I put all of the html code together below. You'll also notice that I added in the <p> and <br> in where I wanted the line breaks. You can do the same.
  159.  
  160. <FORM>
  161. Name:<input name ="name">
  162. <p>
  163. Age: <input name="age" maxlength="3">
  164. <p>
  165. Enter your password (up to 8 characters):<INPUT TYPE="password" NAME="userpassword" SIZE=8 MAXLENGTH=8 VALUE="default">
  166. <p>
  167. Do you like my page?<INPUT NAME="Example4" VALUE="Yes." >
  168. <p>
  169. What is your favorite fruit?
  170. <P>
  171. <SELECT NAME="fruit" >
  172. <OPTION>Apples
  173. <OPTION>Oranges
  174. <OPTION>Pears
  175. </SELECT> 
  176. <P>
  177. What months do you like below?
  178. <P>
  179. <INPUT TYPE="CHECKBOX" NAME="Jan"  CHECKED>January<BR>
  180. <INPUT TYPE="CHECKBOX" NAME="Feb">February<BR>
  181. <INPUT TYPE="CHECKBOX" NAME="Mar"  CHECKED>March<BR>
  182. <INPUT TYPE="CHECKBOX" NAME="Apr">April
  183. <p>
  184. What is your favorite computer?
  185. <BR>
  186. <INPUT TYPE="radio" NAME="computer" VALUE="Macintosh">Macintosh <BR>
  187. <INPUT TYPE="radio" NAME="computer" VALUE="ibm" CHECKED>ibm<BR>
  188. <p>
  189. Please enter your comments:
  190. <TEXTAREA name="comments" ROWS=5 COLS=60>
  191. Some default comments
  192. </TEXTAREA>
  193. <p>
  194. <INPUT TYPE="SUBMIT" Value="Submit">
  195. <INPUT TYPE="RESET" Value="Reset">
  196. </FORM>
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.     Now you have learned the basics of making forms. This form will not work because it needs a cgi-script from an internet server to retrieve the data and send it to you. I know that Geocities (see Free Web Utilities) has a script for this. Just read their instructions on using the script to make it work for you. 
  233.  
  234.  
  235.  
  236.  
  237.